package com.yeyks.rocketmq.service.customer;

//import com.aliyun.openservices.ons.api.Action;
//import com.aliyun.openservices.ons.api.ConsumeContext;
//import com.aliyun.openservices.ons.api.Message;
//import com.aliyun.openservices.ons.api.MessageListener;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.yeyks.commonReference.service.consumer.UserCouponInfoService;
//import com.yeyks.consumer.dal.dao.RechargeRecordMapper;
//import com.yeyks.consumer.dal.domain.RechargeRecord;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;


/**
 * @author fuchangshuai
 * @date 2019/08/09 16:06
 */
//@Slf4j
//@Component
//public class BigGiftCancleListener implements MessageListener {
public class BigGiftCancleListener{

//    @Autowired
//    private RechargeRecordMapper rechargeRecordMapper;
//    @Autowired
//    private UserCouponInfoService userCouponService;
//
//    @Override
//    public Action consume(Message message, ConsumeContext consumeContext) {
//        try {
//            Long startTime = System.currentTimeMillis();
//            byte[] body = message.getBody();
//            String msg = new String(body);
//            //处理业务逻辑
//            disposeLogic(msg);
//            log.info("小黑鱼礼包取消检测：监听到的消息：message = {}", msg);
//            Long endTime = System.currentTimeMillis();
//            log.info("小黑鱼礼包取消检测：单次消费耗时：" + (endTime - startTime) / 1000);
//        } catch (Exception e) {
//            log.error("MessageListener.consume error:" + e.getMessage(), e);
//        }
//        return Action.CommitMessage;
//    }
//
//    private void disposeLogic(String orderNo) {
//        try {
//            //通过订单号查询订单
//            RechargeRecord rechargeRecordEntity = rechargeRecordMapper.selectOne(new QueryWrapper<RechargeRecord>()
//                    .eq(RechargeRecord.ORDER_NO, orderNo).eq(RechargeRecord.STATUS, 1).last("limit 1"));
//            if (null != rechargeRecordEntity) {
//                rechargeRecordEntity.setStatus(3);
//                //回滚券
//                userCouponService.giveSmallBlackFishSpreeFail(orderNo);
//                //修改订单的状态
//                rechargeRecordMapper.updateById(rechargeRecordEntity);
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//            log.error("小黑鱼礼包取消检测：处理监听消息异常：msg = {}", orderNo);
//        }
//    }
}
